Skip to content

vmh: limit additional buffers to non-Linux configurations#10709

Merged
kv2019i merged 1 commit intothesofproject:mainfrom
lyakh:vmh
Apr 27, 2026
Merged

vmh: limit additional buffers to non-Linux configurations#10709
kv2019i merged 1 commit intothesofproject:mainfrom
lyakh:vmh

Conversation

@lyakh
Copy link
Copy Markdown
Collaborator

@lyakh lyakh commented Apr 19, 2026

Commit 7f66827 ("zephyr: alloc: add 32K virtual heap bucket") unconditionally added 256k to Virtual Heap buckets. Make this conditional on a Kconfig option.

Commit 7f66827 ("zephyr: alloc: add 32K virtual heap bucket")
unconditionally added 256k to Virtual Heap buckets. Make this
conditional on a Kconfig option.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the extra 32KB virtual heap bucket (and corresponding virtual heap region size) configurable so Linux builds can reclaim that memory for virtual page/region bookkeeping.

Changes:

  • Add a VIRTUAL_HEAP_EXTENDED Kconfig option (default y) to control whether the additional VMH buffers are included.
  • Conditionally include the 32KB VMH bucket in zephyr/lib/alloc.c when VIRTUAL_HEAP_EXTENDED=y.
  • Disable VIRTUAL_HEAP_EXTENDED in the Linux overlay, which also reduces the default SOF_ZEPHYR_VIRTUAL_HEAP_REGION_SIZE accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
zephyr/lib/alloc.c Wraps the 32KB VMH bucket behind CONFIG_VIRTUAL_HEAP_EXTENDED.
zephyr/Kconfig Introduces VIRTUAL_HEAP_EXTENDED and makes virtual heap region size default conditional.
app/os_linux_overlay.conf Disables VIRTUAL_HEAP_EXTENDED for Linux builds to free VM space for virtual regions/pages.

@wjablon1
Copy link
Copy Markdown
Contributor

Is this solution intended for the gradual shrinkage of the WHM region as we transition towards vregions? I.e. are you going to put more buffers under the Kconfig option/ifdef in the future?

@lgirdwood
Copy link
Copy Markdown
Member

Is this solution intended for the gradual shrinkage of the WHM region as we transition towards vregions? I.e. are you going to put more buffers under the Kconfig option/ifdef in the future?

Yeah, we need to have incremental changes here via Kconfig so we can transition safely, fwiw we also have to coalesce our L1/L2 page tables as they are spread out in virtual space making larger continuous virtual buffer allocations more problematic (see purple boxes in map).
Screenshot From 2026-04-21 16-53-31

@wjablon1
Copy link
Copy Markdown
Contributor

@lgirdwood Thanks for clarification.

Just one minor suggestion: If we expect a really longer transition period, I would reverse the logic Kconfig and call it "Limit the Virtual Heap" instead of "Extend ..." just to emphasize that the VMH is being shrunk.

@lgirdwood
Copy link
Copy Markdown
Member

@lgirdwood Thanks for clarification.

Just one minor suggestion: If we expect a really longer transition period, I would reverse the logic Kconfig and call it "Limit the Virtual Heap" instead of "Extend ..." just to emphasize that the VMH is being shrunk.

Ack - sounds good to me.

@lyakh
Copy link
Copy Markdown
Collaborator Author

lyakh commented Apr 27, 2026

Is this solution intended for the gradual shrinkage of the WHM region as we transition towards vregions? I.e. are you going to put more buffers under the Kconfig option/ifdef in the future?

@wjablon1 please check the PR description. The main purpose of this PR is to limit the effects of another recent PR. So it isn't reducing the scope of VMH, but returning it to a slightly earlier state. However, if we want to keep this Kconfig and re-use it in the future to further shrink VMH, sure, we can rename it.

@abonislawski
Copy link
Copy Markdown
Member

I thought we would simply shrink VMH along with moving allocations, which was supposed to happen shortly but its again 0x100000?

@lyakh
Copy link
Copy Markdown
Collaborator Author

lyakh commented Apr 27, 2026

I thought we would simply shrink VMH along with moving allocations, which was supposed to happen shortly but its again 0x100000?

@abonislawski #10702 switches some allocations to vregion but I'd rather not add yet another commit to it but restore the state with which it was developed and tested before merging it

Copy link
Copy Markdown
Member

@abonislawski abonislawski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine for me

@kv2019i kv2019i merged commit f66d005 into thesofproject:main Apr 27, 2026
44 of 45 checks passed
@lyakh lyakh deleted the vmh branch April 27, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants